package com.ruoyi.project.module.payRecords.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
import com.ruoyi.project.module.payRecords.domain.PayRecords;
import com.ruoyi.project.module.payRecords.service.IPayRecordsService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 交易成功订单记录 信息操作处理
 * 
 * @author frey
 * @date 2018-11-13
 */
@Controller
@RequestMapping("/module/payRecords")
public class PayRecordsController extends BaseController
{
    private String prefix = "module/payRecords";
	
	@Autowired
	private IPayRecordsService payRecordsService;
	
	@RequiresPermissions("module:payRecords:view")
	@GetMapping()
	public String payRecords()
	{
	    return prefix + "/payRecords";
	}
	
	/**
	 * 查询交易成功订单记录列表
	 */
	@RequiresPermissions("module:payRecords:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PayRecords payRecords)
	{
		startPage();
        List<PayRecords> list = payRecordsService.selectPayRecordsList(payRecords);
		return getDataTable(list);
	}
	
	/**
	 * 新增交易成功订单记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存交易成功订单记录
	 */
	@RequiresPermissions("module:payRecords:add")
	@Log(title = "交易成功订单记录", action = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PayRecords payRecords)
	{		
		return toAjax(payRecordsService.insertPayRecords(payRecords));
	}

	/**
	 * 修改交易成功订单记录
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		PayRecords payRecords = payRecordsService.selectPayRecordsById(id);
		mmap.put("payRecords", payRecords);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存交易成功订单记录
	 */
	@RequiresPermissions("module:payRecords:edit")
	@Log(title = "交易成功订单记录", action = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PayRecords payRecords)
	{		
		return toAjax(payRecordsService.updatePayRecords(payRecords));
	}
	
	/**
	 * 删除交易成功订单记录
	 */
	@RequiresPermissions("module:payRecords:remove")
	@Log(title = "交易成功订单记录", action = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(payRecordsService.deletePayRecordsByIds(ids));
	}
	
}
